package com.ruoyi.bysj.service.impl;

import java.util.List;

import com.ruoyi.bysj.domain.SysOrder;
import com.ruoyi.bysj.mapper.SysOrderGoodsMapper;
import com.ruoyi.bysj.mapper.SysOrderMapper;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.bysj.mapper.SysEvaluationMapper;
import com.ruoyi.bysj.domain.SysEvaluation;
import com.ruoyi.bysj.service.ISysEvaluationService;

/**
 * 评价Service业务层处理
 * 
 * @author laow
 * @date 2021-10-27
 */
@Service
public class SysEvaluationServiceImpl implements ISysEvaluationService 
{
    @Autowired
    private SysEvaluationMapper sysEvaluationMapper;

    @Autowired
    private SysOrderMapper sysOrderMapper;

    /**
     * 查询评价
     * 
     * @param evaluationId 评价主键
     * @return 评价
     */
    @Override
    public SysEvaluation selectSysEvaluationByEvaluationId(Long evaluationId)
    {
        return sysEvaluationMapper.selectSysEvaluationByEvaluationId(evaluationId);
    }

    /**
     * 查询评价列表
     * 
     * @param sysEvaluation 评价
     * @return 评价
     */
    @Override
    public List<SysEvaluation> selectSysEvaluationList(SysEvaluation sysEvaluation)
    {
        return sysEvaluationMapper.selectSysEvaluationList(sysEvaluation);
    }

    /**
     * 新增评价
     * 
     * @param sysEvaluation 评价
     * @return 结果
     */
    @Override
    public int insertSysEvaluation(SysEvaluation sysEvaluation)
    {
        SysOrder sysOrder = new SysOrder();
        sysOrder = sysOrderMapper.selectSysOrderByOrderId(sysEvaluation.getOrderId());
        sysOrder.setOrderState("6");
        sysOrderMapper.updateSysOrder(sysOrder);
        sysEvaluation.setGroupId(sysOrder.getGroupId());
        sysEvaluation.setEvaluationTime(DateUtils.getNowDate());
        return sysEvaluationMapper.insertSysEvaluation(sysEvaluation);
    }

    /**
     * 修改评价
     * 
     * @param sysEvaluation 评价
     * @return 结果
     */
    @Override
    public int updateSysEvaluation(SysEvaluation sysEvaluation)
    {
        return sysEvaluationMapper.updateSysEvaluation(sysEvaluation);
    }

    /**
     * 批量删除评价
     * 
     * @param evaluationIds 需要删除的评价主键
     * @return 结果
     */
    @Override
    public int deleteSysEvaluationByEvaluationIds(Long[] evaluationIds)
    {
        return sysEvaluationMapper.deleteSysEvaluationByEvaluationIds(evaluationIds);
    }

    /**
     * 删除评价信息
     * 
     * @param evaluationId 评价主键
     * @return 结果
     */
    @Override
    public int deleteSysEvaluationByEvaluationId(Long evaluationId)
    {
        return sysEvaluationMapper.deleteSysEvaluationByEvaluationId(evaluationId);
    }
}
